﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition.Hosting;
using System.Linq;
using System.Net.Http.Headers;
using System.Reflection;
using System.Text;
using HttpContrib;
using HttpContrib.MediaTypes.StackOverflow;
using HttpContrib.MediaTypes.Standard;
using HttpContrib.Tools;
using RESTAgent;

namespace StackOverflowExplorer {
    class Program {
        static void Main(string[] args) {

            // This sample does not work yet.
            // It needs a static root page to enable discovery.



            // Build catalog of media type handlers
            //var standardCatalog = new AssemblyCatalog(typeof (HtmlHandler).Assembly);
            //var stackOverflowCatalog = new AssemblyCatalog(typeof(StackOverflowDocumentHandler).Assembly);
            
            //var container = new CompositionContainer(aggregateCatalog);  // container is used to provide RestAgent with knowledge of media types
            

            var agent = new RestAgent();
            agent.NavigateTo(new Link(new Uri("http://api.stackoverflow.com/1.0/")));
            agent.AddProductToUserAgent(new ProductHeaderValue("StackOverflowAgent"));


            // This doesn't actually work because the root document that is returned is a help page that points to 
            // other help pages.
            // The plan is to create a HttpPipeline stage that injects a fake root page to compenstate.
            //var link = agent.CurrentContent.Links["/users"];
            //link.AddParameters("filter","Darrel");
            //agent.NavigateTo(link);


        }
    }
}
